
#ifndef __TAPI_PPP_H__
#define __TAPI_PPP_H__


#define NU_CONNECT_TYPE_PPP
#define NU_CONNECT_TYPE_IP

#ifdef NU_CONNECT_TYPE_PPP
typedef int TAPI_PPP_RECV_CB(
    int devid, unsigned char *buffer, unsigned long size);
#endif // NU_CONNECT_TYPE_PPP

#ifdef NU_CONNECT_TYPE_IP
/* after the devid connects, this callback would be invoked*/
typedef void TAPI_IP_CONNECTED_CB(
    int devid, int isconnected);

typedef int TAPI_IP_DOWNLINK_CB(
    int devid, unsigned char *buffer, unsigned long size);

typedef int TAPI_IP_QUERY_DOWNLINK_STATE(
    int devid);

typedef void TAPI_IP_NOTIFY_UPLINK_STATE(
    int devid, unsigned char sig);

#endif // NU_CONNECT_TYPE_IP

struct NU_TAPI_PPP {
#ifdef NU_CONNECT_TYPE_PPP
    // interface for ppp protocol
    void (*ppp_init)(
        TAPI_PPP_RECV_CB *recv_cb);

    void (*ppp_deinit)();

    int (*ppp_send)(
        int devid, unsigned char *buffer_ptr, unsigned long size);

    void (*ppp_free)(void *); // free the send buffer
#endif // NU_CONNECT_TYPE_PPP

#ifdef NU_CONNECT_TYPE_IP
    // interface for tcp/ip protocol
    void (*ip_init)(
        TAPI_IP_CONNECTED_CB *conn_cb,
        TAPI_IP_DOWNLINK_CB *downlink_cb,
        TAPI_IP_QUERY_DOWNLINK_STATE *query_downlink_state, // PS queries MMI
        TAPI_IP_NOTIFY_UPLINK_STATE *notify_state); // PS notifies MMI

    void (*ip_deinit)();

    int (*ip_uplink)(
        int devid, unsigned char *buffer_ptr, unsigned long size);

	unsigned long (*ip_get_uplink_buf)(int devid, unsigned long size); // MMI queries PS

    void (*ip_notify_downlink_ready)(int devid);

    void *(*ip_alloc)(int size);

    void (*ip_free)(void *); // free the send buffer

    void (*ip_get_addr)(
        unsigned char cid, unsigned long *ip, unsigned long *mask,
        unsigned long *gw, unsigned long *dns1, unsigned long *dns2);
#endif // NU_CONNECT_TYPE_IP
};

#endif /* __TAPI_PPP_H__ */

